home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacMarlais 0.5.3 / DIRM Examples / fact.dyl next >
Encoding:
Text File  |  1994-09-19  |  461 b   |  27 lines  |  [TEXT/Mrls]

  1. module:            dylan-user
  2. author:            Patrick C. Beard (beard@cs.ucdavis.edu)
  3. copyright:            (C) 1994 Patrick C. Beard
  4.                 All rights reserved.
  5. synopsis:            
  6. version:            1.0
  7.  
  8. //
  9. // DIRM syntax implementations of factorial and fibonacci functions.
  10. //
  11.  
  12. define method fact(n :: <integer>)
  13.     if (n = 0)
  14.         1;
  15.     else
  16.         n * fact(n - 1);
  17.     end if;
  18. end method fact;
  19.  
  20. define method fib(n :: <integer>)
  21.     if (n = 0 | n = 1)
  22.         1;
  23.     else
  24.         fib(n - 2) + fib(n - 1);
  25.     end if;
  26. end method fib;
  27.